def main():
    file = open("./ips")
    s =  file.readlines()

    listip = []
    for line in s:
        lineWithoutEndl = line.rstrip()
            
        #ipRange = lineWithoutEndl.split('-')
        binRange = convertRange(lineWithoutEndl.split('-'))
        listip.append(binRange)
    
    sortedList = sorted(listip)

    for node in sortedList:
        print revconvertIp(node[0]) + " - " + revconvertIp(node[1])
        
    #print str(listip)
        
    
    # testing covertIp
    #print convertIp("1.168.3.5")

    # testing revcovertIp
    #print revconvertIp("11000000101010000000001100000101")
        
def convertRange(ipRange):
    convertedList = []
    for ip in ipRange:
        convertedList.append(convertIp(ip))

    return convertedList

def convertIp(ip):
    ipPartsList = ip.split('.')
    strIp=""
    for num in ipPartsList:        
        strIp += "{:08b}".format(int(num))
    #Checking if it is 32 bit
    if len(strIp) != 32:
        print "Error convertIp function"
        
    return strIp

def revconvertIp(ip):
    j = 0
    i = 8
    newip = ""
    while i != 40:
        part = str(ip)[j:i]    
        newip += str((int(part,2))) + '.'
        i += 8
        j += 8
    return newip.rstrip('.')


    

main()



